package com.yanma.erp.login.controller;

import com.yanma.erp.comm.ResultParams;
import com.yanma.erp.domain.SysUser;
import com.yanma.erp.login.service.SysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * Created by Kenry.Xian on 2016/2/12 0012.
 */
@Controller
/*@RequestMapping("/")*/
public class LoginController {
    @Autowired
    private SysUserService userService;

    @RequestMapping("/login")
    @ResponseBody
    public Map<String, Object> login(HttpServletRequest request, @RequestParam("name")String userName,
                                     @Param("pwd")String pwd){
        
        ResultParams resultParams = new ResultParams();
        SysUser user = userService.findUserByName(userName);
        resultParams.addAttribute("user", user);
        return resultParams.getResult();
    }

}
